<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

	<title>Class: S3aps::Runner</title>

	<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />

	<script src="../js/jquery.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/thickbox-compressed.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/quicksearch.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../js/darkfish.js" type="text/javascript"
		charset="utf-8"></script>

</head>
<body class="class">

	<div id="metadata">
		<div id="home-metadata">
			<div id="home-section" class="section">
        <h3 class="section-header">
          <a href="../index.html">Home</a>
          <a href="../index.html#classes">Classes</a>
          <a href="../index.html#methods">Methods</a>
        </h3>
			</div>
		</div>

		<div id="file-metadata">
			<div id="file-list-section" class="section">
				<h3 class="section-header">In Files</h3>
				<div class="section-body">
					<ul>
					
						<li><a href="../lib/s3aps/runner_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
							class="thickbox" title="lib/s3aps/runner.rb">lib/s3aps/runner.rb</a></li>
					
					</ul>
				</div>
			</div>

			
		</div>

		<div id="class-metadata">

			<!-- Parent Class -->
			
			<div id="parent-class-section" class="section">
				<h3 class="section-header">Parent</h3>
				
				<p class="link">Object</p>
				
			</div>
			

			<!-- Namespace Contents -->
			

			<!-- Method Quickref -->
			
			<div id="method-list-section" class="section">
				<h3 class="section-header">Methods</h3>
				<ul class="link-list">
					
					<li><a href="#method-c-new">::new</a></li>
					
					<li><a href="#method-i-list">#list</a></li>
					
					<li><a href="#method-i-pull">#pull</a></li>
					
					<li><a href="#method-i-push">#push</a></li>
					
				</ul>
			</div>
			

			<!-- Included Modules -->
			
		</div>

		<div id="project-metadata">
			
			

			<div id="classindex-section" class="section project-section">
				<h3 class="section-header">Class Index
					<span class="search-toggle"><img src="../images/find.png"
						height="16" width="16" alt="[+]"
						title="show/hide quicksearch" /></span></h3>
				<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
				<fieldset>
					<legend>Quicksearch</legend>
					<input type="text" name="quicksearch" value=""
						class="quicksearch-field" />
				</fieldset>
				</form>

				<ul class="link-list">
				
					<li><a href="../S3aps/FileAdapter.html">S3aps::FileAdapter</a></li>
				
					<li><a href="../S3aps/Runner.html">S3aps::Runner</a></li>
				
					<li><a href="../S3aps/S3Adapter.html">S3aps::S3Adapter</a></li>
				
					<li><a href="../S3aps/Sync.html">S3aps::Sync</a></li>
				
				</ul>
				<div id="no-class-search-results" style="display: none;">No matching classes.</div>
			</div>

			
		</div>
	</div>

	<div id="documentation">
		<h1 class="class">S3aps::Runner</h1>

		<div id="description">
			<p>
Allows you to run S3aps from the command line
</p>

		</div>

		<!-- Constants -->
		

		<!-- Attributes -->
		
		<div id="attribute-method-details" class="method-section section">
			<h3 class="section-header">Attributes</h3>

			
			<div id="argv-attribute-method" class="method-detail">
				<a name="argv"></a>
				
				<a name="argv="></a>
				
				<div class="method-heading attribute-method-heading">
					<span class="method-name">argv</span><span
						class="attribute-access-type">[RW]</span>
				</div>

				<div class="method-description">
				
				
				
				</div>
			</div>
			
		</div>
		

		<!-- Methods -->
		
		<div id="public-class-method-details" class="method-section section">
			<h3 class="section-header">Public Class Methods</h3>

		
			<div id="new-method" class="method-detail ">
				<a name="method-c-new"></a>

				<div class="method-heading">
				
					<span class="method-name">new</span><span
						class="method-args">(argv)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					
					

					
					<div class="method-source-code"
						id="new-source">
<pre>
    <span class="ruby-comment cmt"># File lib/s3aps/runner.rb, line 12</span>
12:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">argv</span>)
13:       <span class="ruby-ivar">@options</span> = {}
14:       <span class="ruby-ivar">@cmd</span> = <span class="ruby-value">:help</span>
15:       <span class="ruby-ivar">@option_parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
16:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-value str">S3aps version #{S3aps::VERSION}Usage: s3aps (list|pull|push|version) [OPTIONS]  list  List files locally and remotely  pull  Pull new files from remote  push  Push new files to remote (be careful)</span>
17:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-c&quot;</span>, <span class="ruby-value str">&quot;--config FILE&quot;</span>, <span class="ruby-value str">&quot;YAML file containing S3 credentials&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:config</span>] = <span class="ruby-identifier">name</span> }
18:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-e&quot;</span>, <span class="ruby-value str">&quot;--env ENV&quot;</span>, <span class="ruby-value str">&quot;Section of YAML to use&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:env</span>] = <span class="ruby-identifier">name</span> }
19:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-b&quot;</span>, <span class="ruby-value str">&quot;--bucket NAME&quot;</span>, <span class="ruby-value str">&quot;S3 bucket name&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:bucket</span>] = <span class="ruby-identifier">name</span> }
20:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-k&quot;</span>, <span class="ruby-value str">&quot;--key KEY&quot;</span>, <span class="ruby-value str">&quot;S3 access key&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:key</span>] = <span class="ruby-identifier">name</span> }
21:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-s&quot;</span>, <span class="ruby-value str">&quot;--secret KEY&quot;</span>, <span class="ruby-value str">&quot;S3 secret key&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:secret</span>] = <span class="ruby-identifier">name</span> }
22:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--path PATH&quot;</span>, <span class="ruby-value str">&quot;Local path&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:path</span>] = <span class="ruby-identifier">name</span> }
23:         <span class="ruby-identifier">o</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">argv</span>)
24:       <span class="ruby-keyword kw">end</span>
25:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-node">%(list push pull version)</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">argv</span>.<span class="ruby-identifier">first</span>)
26:         <span class="ruby-ivar">@sync</span> = <span class="ruby-constant">S3aps</span><span class="ruby-operator">::</span><span class="ruby-constant">Sync</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@options</span> 
27:         <span class="ruby-ivar">@cmd</span> = <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">first</span>
28:       <span class="ruby-keyword kw">end</span>
29:         <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	
		<div id="public-instance-method-details" class="method-section section">
			<h3 class="section-header">Public Instance Methods</h3>

		
			<div id="list-method" class="method-detail ">
				<a name="method-i-list"></a>

				<div class="method-heading">
				
					<span class="method-name">list</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Prints out a list of all remote and local files and shows which ones are
remote, local or both.
</p>
					

					
					<div class="method-source-code"
						id="list-source">
<pre>
    <span class="ruby-comment cmt"># File lib/s3aps/runner.rb, line 53</span>
53:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>
54:       <span class="ruby-identifier">array</span> = <span class="ruby-ivar">@sync</span>.<span class="ruby-identifier">list</span>
55:       <span class="ruby-identifier">local_count</span> = <span class="ruby-value">0</span>
56:       <span class="ruby-identifier">remote_count</span> = <span class="ruby-value">0</span>
57:       <span class="ruby-identifier">array</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
58:         <span class="ruby-identifier">line</span> = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
59:         <span class="ruby-identifier">local_count</span> <span class="ruby-operator">+=</span><span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^L\s\s/</span>
60:         <span class="ruby-identifier">remote_count</span> <span class="ruby-operator">+=</span><span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^\s\sR/</span>
61:         <span class="ruby-identifier">puts</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
62:       <span class="ruby-keyword kw">end</span>
63:       <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Found #{array.size} file(s): #{local_count} local only, #{remote_count} remote only, #{array.size - local_count - remote_count} common.&quot;</span>
64:     <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="pull-method" class="method-detail ">
				<a name="method-i-pull"></a>

				<div class="method-heading">
				
					<span class="method-name">pull</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Pull files from S3
</p>
					

					
					<div class="method-source-code"
						id="pull-source">
<pre>
    <span class="ruby-comment cmt"># File lib/s3aps/runner.rb, line 67</span>
67:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pull</span>
68:           <span class="ruby-identifier">count</span>, <span class="ruby-identifier">total</span> = <span class="ruby-ivar">@sync</span>.<span class="ruby-identifier">pull</span> 
69:       <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;\nPulled #{count}/#{total} file#{'s' unless count == 1} from S3&quot;</span>
70:         <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="push-method" class="method-detail ">
				<a name="method-i-push"></a>

				<div class="method-heading">
				
					<span class="method-name">push</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Push files to S3
</p>
					

					
					<div class="method-source-code"
						id="push-source">
<pre>
    <span class="ruby-comment cmt"># File lib/s3aps/runner.rb, line 73</span>
73:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">push</span>
74:       <span class="ruby-identifier">count</span>, <span class="ruby-identifier">total</span> = <span class="ruby-ivar">@sync</span>.<span class="ruby-identifier">push</span>
75:       <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;\nPushed #{count} file#{'s' unless count == 1} to S3&quot;</span>
76:         <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	

	</div>


	<div id="rdoc-debugging-section-dump" class="debugging-section">
	
		<p>Disabled; run with --debug to generate this.</p>
	
	</div>

	<div id="validator-badges">
		<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
		<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
			Rdoc Generator</a> 1.1.6</small>.</p>
	</div>

</body>
</html>

